# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=spice-gtk
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.31
pkgrel=1
arch=('any')
pkgdesc="GTK3 widget for SPICE clients (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-cyrus-sasl"
         "${MINGW_PACKAGE_PREFIX}-dbus-glib"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-lz4"
         "${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-phodav"
         "${MINGW_PACKAGE_PREFIX}-pixman"
         "${MINGW_PACKAGE_PREFIX}-spice-protocol"
         "${MINGW_PACKAGE_PREFIX}-usbredir"
         "${MINGW_PACKAGE_PREFIX}-vala")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             #"${MINGW_PACKAGE_PREFIX}-python2-pygtk"
             "${MINGW_PACKAGE_PREFIX}-python2")
options=('strip' 'staticlibs')
license=("GPL 2")
url="http://www.spice-space.org"
source=(http://www.spice-space.org/download/gtk/${_realname}-${pkgver}.tar.bz2
        001-win.patch
        003-python-linking.patch)
sha256sums=('c72b4d202b1c0b71d6e24ce5caf914d6dddbcf4010d10db9c2d8e73af728c1ca'
            'f2a623c7268ef7c5a0a2084a4698b0d7c7c0e6fd067f2419c21d95c5b3fdf2d6'
            'bd4f60a9ff6c00f588d36721b22f1abeb3edf91c9f81916c80aaa71bafc755a0')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/001-win.patch
  patch -p1 -i ${srcdir}/003-python-linking.patch

  autoreconf -isf
}

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-introspection \
    --enable-vala \
    --enable-lz4 \
    --with-gtk=3.0 \
    --without-python \
    --with-audio=no

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
